#ifndef __REGISTER_CLASSES_H__
#define __REGISTER_CLASSES_H__

#include <godot_cpp/variant/utility_functions.hpp>
#include <unordered_map>

#define CHECK_INSTANCE_VALID(val)                                                          \
	{                                                                                      \
		JSValue undefined = JS_UNDEFINED;												   \
		JSClassID class_id = 0;															   \
		void *opaque = JS_GetAnyOpaque(val, &class_id);									   \
		VariantAdapter *adapter = reinterpret_cast<VariantAdapter *>(opaque);              \
		godot::Object *object = static_cast<godot::Object *>(adapter->get());              \
		ERR_FAIL_COND(!UtilityFunctions::is_instance_id_valid(object->get_instance_id())); \
	}

#define CHECK_INSTANCE_VALID_V(val)                                                                     \
	{                                                                                                   \
		JSValue undefined = JS_UNDEFINED;																\
		JSClassID class_id = 0;																			\
		void *opaque = JS_GetAnyOpaque(val, &class_id);													\
		VariantAdapter *adapter = reinterpret_cast<VariantAdapter *>(opaque);                           \
		godot::Object *object = static_cast<godot::Object *>(adapter->get());                           \
		ERR_FAIL_COND_V(!UtilityFunctions::is_instance_id_valid(object->get_instance_id()), undefined); \
	}


{% for class in classes %}	
{% if class.name == 'Object' %}
void register_godot_object();
{% endif %}
void register_{{ camel_to_snake(class['name']) }}();
{% endfor %}
void register_classes();
#endif // __REGISTER_CLASSES_H__